<?PHP

class mvSettings{

	static $settings 	= array();

	public static function __set_state($a){
		self::$settings = $a['settings'];
	}

	public static function save($file){
		$output = '';
		// legacy config options
		$output = "<?php // config.php
define ('KBINSTALL' ,'".self::get('kbinstall', 0)."');
define ('KBNAME' , '".self::get('kbname', 'Pomby')."');
define ('KBURL' ,'".self::get('kburl', 'http://localhost/pomby/')."');
define ('KBHOMEURL', '".self::get('kbhomeurl', 'http://pomby.com')."');
define ('DB_USER', '".self::get('db_user', 'root')."');
define ('DB_PASSWORD', '".self::get('db_password', '')."');
define ('DB_HOST', '".self::get('db_host', 'localhost')."');
define ('DB_NAME', '".self::get('db_name', 'pomby')."');
define ('DB_MAX_REC', '".self::get('db_max_rec', 10)."');
define ('PLUGINHTML' , '".self::get('kbname', 1)."');
define ('PLUGINPDF' , '".self::get('kbname', 1)."');
define ('PLUGINRSS' , '".self::get('kbname', 1)."');
define ('PRODLEV' , '".self::get('kbname', 0)."');
";

		// Actual settings output
		$a = new mvSettings;
		$a->settings = self::$settings;
		$output .= "if(class_exists('mvSettings')) " . var_export($a, true) . "; \n?>";

		file_put_contents($file, $output);
	}

	public static function get($var, $default = false){
		if(isset(self::$settings[$var]))
			return self::$settings[$var];

		return $default;
	}

	public static function set($var, $value){
		self::$settings[$var] = $value;
	}

}

?>